home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #48 (Sep 89) / Zoundz Source / save_changes.Pas < prev    next >
Pascal/Delphi Source File  |  1989-05-08  |  1KB  |  59 lines

  1. unit save_changes;
  2.  
  3. interface
  4.  
  5.     function D_save_changes: integer;
  6.  
  7. implementation
  8.  
  9.     const                               {These are the item numbers for controls in the Dialog}
  10.         I_Yes = 1;
  11.         I_Cancel = 2;
  12.         I_No = 3;
  13.         I_x = 4;
  14.     var
  15.         ExitDialog: boolean;           {Flag used to exit the Dialog}
  16.         DoubleClick: boolean;          {Flag to say that a double click on a list happened}
  17.         MyPt: Point;                   {Current list selection point}
  18.         MyErr: OSErr;                  {OS error returned}
  19.  
  20.     function D_save_changes;
  21.         var
  22.             GetSelection: DialogPtr;
  23.             tempRect: Rect;
  24.             DType: Integer;
  25.             DItem: Handle;
  26.             itemHit: Integer;
  27.  
  28.         procedure Refresh_Dialog;           {Refresh the dialogs non-controls}
  29.             var
  30.                 rTempRect: Rect;             {Temp rectangle used for drawing}
  31.  
  32.         begin
  33.             SetPort(GetSelection);      {Point to our dialog window}
  34.             GetDItem(GetSelection, I_Yes, DType, DItem, tempRect);
  35.             PenSize(3, 3);
  36.             InsetRect(tempRect, -4, -4);
  37.             FrameRoundRect(tempRect, 16, 16);
  38.             PenSize(1, 1);
  39.         end;
  40.  
  41.     begin                           {Start of dialog handler}
  42.         GetSelection := GetNewDialog(3, nil, Pointer(-1));
  43.         ShowWindow(GetSelection);
  44.         SelectWindow(GetSelection);
  45.         SetPort(GetSelection);
  46.  
  47.         Refresh_Dialog;
  48.  
  49.         ExitDialog := FALSE;
  50.  
  51.         repeat
  52.             ModalDialog(nil, itemHit);
  53.             D_save_changes := itemHit;
  54.             if (ItemHit = I_Yes) or (ItemHit = I_Cancel) or (ItemHit = I_No) then
  55.                 ExitDialog := TRUE;
  56.         until ExitDialog;
  57.         DisposDialog(GetSelection);
  58.     end;
  59. end.                                {End of unit}